package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.MemberReportVO;
import com.itheima.health.pojo.SetmealReportVO;
import com.itheima.health.result.Result;
import com.itheima.health.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * 数据统计功能开发
 */
@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {

    @Autowired
    private ReportService reportService;

    /**
     * 会员数据统计
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport(){

        //将字符串解析为LocalDate对象,它需要一个字符串参数,字符串参数必须遵循日期格式
        LocalDate begin = LocalDate.parse("2023-5-01");
        LocalDate end = LocalDate.parse("2023-5-07");

        MemberReportVO  memberReportVO = reportService.getMemberReport(begin,end);
        return new Result(true, MessageConst.ADD_MEMBER_SUCCESS,memberReportVO);
    }


    /**
     * 套餐预约占比饼形图
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport(){

        SetmealReportVO setmealReportVO = reportService.getSetmealReport();
        return new Result(true,MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,setmealReportVO);
    }
}
